Skip to content

Conversation

@cyfung1031
Copy link
Collaborator

@cyfung1031 cyfung1031 changed the title ScriptEditor: 脚本名称冲突 (合并至 develop/scripteditor-1) [v1.3] ScriptEditor: 脚本名称冲突 (合并至 develop/scripteditor-1) Feb 7, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 在 ScriptEditor 的保存流程中新增“脚本名称 + namespace 冲突”检测:当新增脚本或修改脚本名称/命名空间时,如发现已有同名同命名空间脚本,则弹窗提醒用户是否仍要保存,以避免同页重复运行脚本的问题(#808)。

Changes:

  • 保存时检测同名同 namespace 脚本,冲突时弹出确认对话框,可选择继续保存或中止保存
  • 为该提示补充多语言文案(zh-CN/zh-TW/en-US/de-DE/ja-JP/ru-RU/vi-VN/ach-UG)

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/pages/options/routes/script/ScriptEditor.tsx 在保存逻辑中加入脚本名称冲突检测与确认弹窗
src/locales/zh-TW/translation.json 新增脚本名称冲突相关文案(繁中)
src/locales/zh-CN/translation.json 新增脚本名称冲突相关文案(简中)
src/locales/vi-VN/translation.json 新增脚本名称冲突相关文案(越南语)
src/locales/ru-RU/translation.json 新增脚本名称冲突相关文案(俄语)
src/locales/ja-JP/translation.json 新增脚本名称冲突相关文案(日语)
src/locales/en-US/translation.json 新增脚本名称冲突相关文案(英文)
src/locales/de-DE/translation.json 新增脚本名称冲突相关文案(德文)
src/locales/ach-UG/translation.json 新增脚本名称冲突相关文案(ach-UG)

setTimeout(e.focus.bind(e), 50);
if (modalResult === "no") {
Message.warning(t("save_abort_when_scriptname_conflict"));
return Promise.reject(new Error("This script name is already used by another script. Save aborted."));
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里在用户选择“不保存”时通过 Promise.reject(new Error(...)) 中止流程,会被外层 save().catch() 统一当作 invalid_script_code 处理并弹出错误提示;同时 run 菜单里 await save(...) 没有兜底 catch,取消保存会导致运行流程抛错/潜在未处理的 Promise rejection。建议为“用户主动取消保存”使用可识别的中止信号(如专用错误类型/错误码),并在 save() 的 catch 中对该类中止分支直接静默返回/仅保留 warning,不要走 invalid_script_code 提示;调用方(如 run)也应捕获并直接 return。

Suggested change
return Promise.reject(new Error("This script name is already used by another script. Save aborted."));
// 用户主动取消保存:中止当前保存流程,但不触发 Promise rejection
return;

Copilot uses AI. Check for mistakes.
@CodFrm
Copy link
Member

CodFrm commented Feb 12, 2026

有问题 这个脚本我有多个版本,如果就是想保留几个不同的版本,体验不是很好(等有用户提再优化也行),似乎 编辑冲突也有些问题

没太细看,我先看其它pr

1234.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 提醒有相同名字的腳本 (安裝/更新/改代碼)

2 participants